package com.example.day09;

import java.util.Iterator;
import java.util.LinkedList;

public class LinkdedListDemo {

    public static void main(String[] args) {
        LinkedList<String>  linkedList=new LinkedList<>();

        linkedList.add("spring");
        linkedList.add("soringmvc");
        linkedList.add("springboot");
        linkedList.add("springcloud");

        System.out.println(linkedList.get(1));

        System.out.println(linkedList.remove(1));

        linkedList.addFirst("mysql");
        linkedList.addLast("linux");

        System.out.println(linkedList.peek());
        linkedList.push("abcd");
        System.out.println(linkedList.pop());

        System.out.println(linkedList.getFirst());
        System.out.println(linkedList.getLast());

        System.out.println("=====================");
        System.out.println(linkedList);

        Iterator<String> iterator=linkedList.iterator();
        while (iterator.hasNext()){
            String s=iterator.next();
            System.out.println(s);
        }
    }
}
